
xvaluefiledata = ''

for paramnum in range(20):
    if paramnum == 0:
        xvaluefiledata += '''
        static std::vector<a8::XValue> CreateXValueArray()
        {
          std::vector<a8::XValue> result;
          return result;
        }
        
        '''
    else:
        xvaluefiledata += 'template<' + \
                          ',\n'.join(['typename _T%d_' % t for t in range(paramnum)]) + \
                          '>\n'
        xvaluefiledata += 'static std::vector<a8::XValue> CreateXValueArray(' + \
                          ',\n'.join(['const _T%d_& t%d' % (t, t) for t in range(paramnum)]) + \
                          ')\n'
        xvaluefiledata += '{\n'
        xvaluefiledata += 'std::vector<a8::XValue> result;\n'
        xvaluefiledata += ';\n'.join(['result.push_back(a8::XValue(t%d))' % t for t in range(paramnum)])
        xvaluefiledata += ''';          
          return result;
        }
        
        '''
#end for
for paramnum in range(20):
    if paramnum == 0:
        xvaluefiledata += '''
        static std::vector<std::pair<std::string, a8::XValue> > CreateXValuePairs()
        {
          std::vector<std::pair<std::string, a8::XValue> > result;
          return result;
        }
        
        '''
    else:
        xvaluefiledata += 'template<' + \
                          ',\n'.join(['typename _T%d_' % t for t in range(paramnum)]) + \
                          '>\n'
        xvaluefiledata += 'static std::vector<a8::XValue> CreateXValuePairs(' + \
                          ',\n'.join(['const char* s%d, const _T%d_& t%d' % (t, t, t) for t in range(paramnum)]) + \
                          ')\n'
        xvaluefiledata += '{\n'
        xvaluefiledata += 'std::vector<std::pair<std::string, a8::XValue> > result;\n'
        xvaluefiledata += ';\n'.join(['result.push_back(std::make_pair(s%d, a8::XValue(t%d)))' % (t, t) for t in range(paramnum)])
        xvaluefiledata += ''';          
          return result;
        }
        
        '''
#end for

fp = open("../a8/inc/xvalue.inl", "w")
fp.write(xvaluefiledata)
fp.close()

#--------------------------------------------------------------------------------------------
mysqlfiledata = ''

for paramnum in range(1, 20):
    mysqlfiledata += 'template<' + \
                     ',\n'.join(['typename _T%d_' % t for t in range(paramnum)]) + \
                     '>\n'
    mysqlfiledata += 'int ExecQuery(const char* queryStr,' + \
                     ',\n'.join(['const _T%d_& t%d' % (t, t) for t in range(paramnum)]) + \
                     ')\n'
    mysqlfiledata += '{\n'
    mysqlfiledata += 'a8::XValue args[] = {\n'
    mysqlfiledata += ',\n'.join(['a8::XValue(t%d)' % t for t in range(paramnum)])
    mysqlfiledata += '''};          
      return ExecQuery(formatsql(queryStr, args, sizeof(args) / sizeof(a8::XValue)).c_str());
    }

    '''
for paramnum in range(1, 20):
    mysqlfiledata += 'template<' + \
                     ',\n'.join(['typename _T%d_' % t for t in range(paramnum)]) + \
                     '>\n'
    mysqlfiledata += 'int ExecScript(const char* queryStr,' + \
                     ',\n'.join(['const _T%d_& t%d' % (t, t) for t in range(paramnum)]) + \
                     ')\n'
    mysqlfiledata += '{\n'
    mysqlfiledata += 'a8::XValue args[] = {\n'
    mysqlfiledata += ',\n'.join(['a8::XValue(t%d)' % t for t in range(paramnum)])
    mysqlfiledata += '''};          
      return ExecScript(formatsql(queryStr, args, sizeof(args) / sizeof(a8::XValue)).c_str());
    }

    '''
#end for

fp = open("../a8/inc/mysql.inl", "w")
fp.write(mysqlfiledata)
fp.close()
